<%@ Page Language="VB" MasterPageFile="~/Default.master" AutoEventWireup="false" CodeFile="Manage.aspx.vb" Inherits="Poll_Manage" title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
       <div id="body">
        <div class="fullwidth">
            <h3>Polls</h3>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                DataKeyNames="PollId" Width="100%" DataSourceID="SqlDataSource1" OnRowUpdating="GridView1_RowUpdating">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="Question" HeaderText="Question" SortExpression="Question" />
                    <asp:BoundField DataField="CreationDate" HeaderText="Date" SortExpression="CreationDate" />
                    <asp:HyperLinkField DataNavigateUrlFields="PollId" DataNavigateUrlFormatString="~/Poll/Answers.aspx?PollId={0}"
                        HeaderText="Answers" Text="&#187;&#187;&#187;" />
                </Columns>
            </asp:GridView>
        </div>
        <!-- Left column -->
        <div id="columnleft">
            <a name="content_start" id="content_start"></a>
            <div class="leftblock">
                On this page you can add new Polls. Steps:
                <ul>
                    <li>First add a question or a statement</li>
                    <li>Next, add a few possible answers for your question or statement.</li>
                </ul>
            </div>
        </div>
        <!-- Right column -->
        <div id="columnright">
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDB %>"
                SelectCommand="SELECT [PollId], [Question], [CreationDate], [MemberId] FROM [PollQuestions]"
                DeleteCommand="DELETE FROM [PollQuestions] WHERE [PollID] = @original_PollId"
                InsertCommand="INSERT INTO [PollQuestions] ([PollId], [Question], [CreationDate], [Memberid]) VALUES (@pollId, @question, @creationDate, @memberid)"
                OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [PollQuestions] SET [Question] = @question, [CreationDate] = @creationDate WHERE [PollId] = @original_PollId">
            </asp:SqlDataSource>
            <div class="rightblock">
                <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="PollQuestionId"
                    Height="50px" Width="100%" DataSourceID="SqlDataSource1" DefaultMode="Insert" OnItemInserting="DetailsView1_ItemInserting">
                    <Fields>
                        <asp:BoundField DataField="PollQuestionId" HeaderText="Question" InsertVisible="False" ReadOnly="True"
                            SortExpression="PollQuestionId" />
                        <asp:TemplateField HeaderText="Question" SortExpression="topic">
                            <InsertItemTemplate>
                                <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Question") %>'></asp:TextBox>
                                <asp:RequiredFieldValidator ControlToValidate="TextBox1" ValidationGroup="Insert"
                                    ID="RequiredFieldValidator1" runat="server" ErrorMessage="Question is required">*</asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField ValidationGroup="Insert" ShowInsertButton="True"
                            ShowCancelButton="False" InsertText="Add Poll" />
                    </Fields>
                </asp:DetailsView>
            </div>
        </div>
    </div>
</asp:Content>